Skip to content
本页内容

FormatConditions (对象)

代表一个区域内所有条件格式的集合。

说明

FormatConditions 集合可以包含多个条件格式。每个格式由一个 FormatCondition 对象代表。

有关条件格式的详细信息,请参阅 FormatCondition 对象。

使用 FormatConditions 属性可返回 FormatConditions 对象。使用 Add 方法可新建条件格式,使用 Modify 方法可更改现有的条件格式。

示例

python
#本示例向第一张工作表上单元格区域 E1:E10 中添加条件格式
def test():
    formatCondition = Application.Worksheets.Item(1).Range("E1:E10").FormatConditions.Add(xlCellValue, xlGreater, "=$A$1")
    boders = formatCondition.Borders
    boders.LineStyle = xlContinuous
    boders.Weight = xlThin
    boders.ColorIndex = 6
    font = formatCondition.Font
    font.Bold = True
    font.ColorIndex = 3
python
#本示例在活动工作表上单元格区域 F1:F10 新增Top10条件格式
def test():
    top = ActiveSheet.Range("F1:F10").FormatConditions.AddTop10()
    top.TopBottom = xlTop10Top
    top.Rank = 5
    top.Percent = False
    top.Font.Bold = True
    top.Interior.ColorIndex = 5